//
//  HACIndexEntry.m
//  Pods
//
//  Created by Hotacool on 2017/9/4.
//
//

#import "HACIndexEntry.h"
#import "HACChartDefine.h"

@implementation HACIndexEntry
- (id)copyWithZone:(NSZone *)zone {
    HACIndexEntry *model = [[self class] allocWithZone:zone];
    model.indexResultCount = self.indexResultCount;
    model.indexResult = [[NSArray alloc]initWithArray:self.indexResult copyItems:YES];
    return model;
}

- (NSInteger)indexResultCount {
    return self.indexResult?self.indexResult.count:0;
}

- (CGFloat)getIdxFromIdxResult:(NSInteger)index {
    if (index < self.indexResult.count) {
        return [self.indexResult[index] floatValue];
    }
    return kDrawingInvaildValue;
}

- (CGFloat)maxIdxValue {
    CGFloat maxValue = FLT_MIN;
    for (NSNumber *idxValue in self.indexResult) {
        CGFloat value = [idxValue floatValue];
        if (value != kDrawingInvaildValue && value > maxValue) {
            maxValue = value;
        }
    }
    maxValue = (maxValue == FLT_MIN) ? kDrawingInvaildValue : maxValue;
    //    CGFloat maxValue = [[self.klineIdxResult valueForKeyPath:@"@max.floatValue"] floatValue];
    return maxValue;
}

- (CGFloat)minIdxValue {
    CGFloat minValue = FLT_MAX;
    for (NSNumber *idxValue in self.indexResult) {
        CGFloat value = [idxValue floatValue];
        if (value != kDrawingInvaildValue && value < minValue) {
            minValue = value;
        }
    }
    minValue = (minValue == FLT_MAX) ? kDrawingInvaildValue : minValue;
    return minValue;
}

@end

@implementation HACKLineMAEntry
- (CGFloat)ma1 { return [self getIdxFromIdxResult:0]; }
- (CGFloat)ma2 { return [self getIdxFromIdxResult:1]; }
- (CGFloat)ma3 { return [self getIdxFromIdxResult:2]; }
- (CGFloat)ma4 { return [self getIdxFromIdxResult:3]; }
- (CGFloat)ma5 { return [self getIdxFromIdxResult:4]; }
- (CGFloat)ma6 { return [self getIdxFromIdxResult:5]; }
@end

@implementation HACTecMACDEntry
@end

@implementation HACTecKDJEntry
@end

@implementation HACTecRSIEntry
@end

@implementation HACTecBOLLEntry
@end

@implementation HACTecPSYEntry
@end

@implementation HACTecOBVEntry
@end

@implementation HACTecDMIEntry
@end

@implementation HACTecDMIDIEntry
@end

@implementation HACTecWREntry
@end

@implementation HACTecASIEntry
@end

@implementation HACTecDMAEntry
@end

@implementation HACTecBIASEntry
@end

@implementation HACTecVREntry
@end

@implementation HACTecCCIEntry
@end

@implementation HACTecCCITempEntry
@end
